package com.example.lottery_system.common.exception;

import com.example.lottery_system.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class ControllerException extends RuntimeException{
    /**
     * 异常码
     * @see com.example.lottery_system.common.errorcode.ControllerConstants
     */
    private Integer code;
    /**
     * 异常消息
     */
    private String massage;

    // 不带参的构造函数
    // 目的：为了序列化
    public ControllerException() {

    }

    public ControllerException(Integer code, String massage) {
        this.code = code;
        this.massage = massage;
    }

    public ControllerException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.massage = errorCode.getMsg();
    }
}
